//
//  JJAppConfigManager.swift
//  swiftStudy
//
//  Created by hamilyjing on 2020/6/26.
//  Copyright © 2020 JJ. All rights reserved.
//

import Foundation

class JJAppConfigManager {
    var appConfig:[String: Any]
    
    static let shared = JJAppConfigManager()
    
    private init() {
        let filePath = Bundle.main.path(forResource: "JJAppConfig", ofType: "json")
        var data: Data?
        do {
            data = try Data(contentsOf: URL(fileURLWithPath: filePath!))
        } catch let error as NSError {
            assert(false, error.description)
        }
        
        appConfig = data!.jjs_dictionary() as! [String: Any]
    }
    
    func isDebug() -> Bool {
        let isDebug = appConfig["IsDebug"] as! Bool
        return isDebug
    }
    
    func environmentName() -> String {
        let environmentName = appConfig["EnvironmentName"] as! String
        return environmentName
    }
}
